package cn.zz.veggie.web.types.dto.mgmt.order;

import java.util.Collection;
import java.util.List;

import cn.zz.comm.exception.classes.ParamInvalidException;
import cn.zz.veggie.model.domain.Order;
import cn.zz.veggie.core.enums.biz.OrderStatus;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;

/**
 * @author zhongq
 * @since 2024/6/3
 */
public class MgmtOrderStatusDto {

	@NotEmpty
	@NotNull
	private List<@Positive Integer> ids;
	@NotNull
	@Positive
	private Integer status;

	public void requireValid(Collection<Order> orders) {
		if (orders.size() != ids.size()) {
			throw new ParamInvalidException("ids size not match ");
		}
		if (orders.stream().anyMatch(o -> !OrderStatus.canChangeTo(o.getStatus(), status))) {
			// TODO 2024/6/3 21:16
			throw new ParamInvalidException("status not all ");
		}
	}

	public List<Integer> getIds() {
		return ids;
	}

	public void setIds(List<Integer> ids) {
		this.ids = ids;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
}